<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title>众心起盒团膳</title>
	<link rel="stylesheet" href="css/weui.min.css" />
	<link rel="stylesheet" href="fonts/iconfont.css" />
	 <link rel="stylesheet" href="./fonts/qiheicon.css" />
	<link rel="stylesheet" href="css/style.css" />
	<link rel="stylesheet" href="css/home.css" />
	<script src="js/jquery-2.2.3.min.js"></script>
	<!-- <script src="js/weui.min.js"></script> -->
</head>


<body ontouchstart>
	<div class="weui-content">
		<div class="weui-flex user-head">
			<div class="touxiang">
				<img id="wxImg" src="" style="width:70px; height:70px; border-radius: 0;">
			</div>
			<div class="weui-flex__item">
				<div><span class="name" id="userName"></span></div>
				<div class="info" id="phone"></div>
				<!-- 积分 -->
				<div class="integral" style="float:left;width:86px;height:20px;background:rgba(14,138,229,1);border-radius:6px;font-size:12px;line-height:20px;text-align: center;margin-right: 14px;margin-top: 5px;">
					<a href="#">1890积分</a>
				</div>
				<div>
					
				</div>
				<div class="info" id="company" style="font-size: 12px;">
					
				</div>
			</div>
		</div>
		<div class="weui-cells nav-order">
			<div class="weui-cell weui-cell_access">
				<div class="weui-cell__bd">我的订单</div>
				<!-- orderAll.html -->
				<a href="#" class="weui-cell__ft weui-cell__ft_in-access more">查看全部</a>
			</div>
			<!-- pendingPayment.html -->
			<div class="weui-cell weui-flex">
				<a href="#" class="weui-flex__item">
					<!-- <div class="iconfont icon-dfk"></div> -->
					<span class="iconqihe-dingdandaifukuan" style="font-size:26px; color:#F94866"></span>
					<div class="txt">
						待付款
					</div>
					<!-- <span class="weui-badge">9</span> -->
				</a>
				<!-- pendingDelivery.html -->
				<a href="#" class="weui-flex__item">
					<!-- <img src="./images/dingdandaifahuo.png"> -->
					<span class="iconqihe-dingdandaifahuo" style="font-size:22px; color:#F94866"></span>
					<div class="txt">待发货</div>
				</a>
				<!-- goodsReceive.html -->
				<a href="#" class="weui-flex__item">
					<!-- <img src="./images/dingdandaishouhuo.png"> -->
					<span class="iconqihe-dingdandaishouhuo" style="font-size:22px; color:#F94866"></span>
					<div class="txt">待收货</div>
				</a>
				<!-- goodsCompleted.html -->
				<a href="#" class="weui-flex__item">
					<!-- <img src="./images/dingdandaipingjia.png"> -->
					<span class="iconqihe-dingdandaipingjia" style="font-size:26px; color:#F94866"></span>
					<div class="txt">待评价</div>
				</a>
			</div>

		</div>
		<div class="weui-cells nav-user">
			<!-- userinfo.html 个人资料 -->
			<a href="userinfo.html" class="weui-cell weui-cell_access">
				<div class="weui-cell__hd"><i class="iconfont icon-user"></i></div>
				<div class="weui-cell__bd">个人资料</div>
				<div class="weui-cell__ft"></div>
			</a>
			<!-- zhanghu.html 财务中心 -->
			<a href="zhanghu.html" class="weui-cell weui-cell_access">
				<div class="weui-cell__hd"><i class="iconfont icon-gold"></i></div>
				<div class="weui-cell__bd">财务中心</div>
				<div class="weui-cell__ft"></div>
			</a>
			<!-- fukuanma.html 付款码 -->
			<a href="fukuanma.html" class="weui-cell weui-cell_access">
				<div class="weui-cell__hd"><i class="iconfont icon-qrcode"></i></div>
				<div class="weui-cell__bd">我的付款码</div>
				<div class="weui-cell__ft"></div>
			</a>
			<!-- fukuanma.html我的优惠券 -->
			<a href="#" class="weui-cell weui-cell_access">
				<div class="weui-cell__hd">
					<img src="./images/youhuiquan.png" class="youhuiquan">
				</div>
				<div class="weui-cell__bd">我的优惠券</div>
				<div class="weui-cell__ft"></div>
			</a>
		</div>
	</div>
	<!-- 点击加入公司的弹窗 -->
	<div class="popup">
		<div class="popup-content-bg"></div>
		<div class="popup-content">
			<img src="./images/weijiarugongs_tubiao@2x.png" alt="">
			<div id="joinText" >
				请联系管理员加入公司
			</div>
			<div id="closePopup" >
				知道了
			</div>
		</div>
	</div>
</body>
<script src="./api.js"></script>
<script>
	window.onload = function () {
		let userinfo = JSON.parse(localStorage.getItem('wxUserInfo')).data
		let getWxImg = localStorage.getItem('getWxImg')
		
		let api = getApi();
        //获取本地缓存的用户信息
        let customerID = JSON.parse(localStorage.getItem('wxUserInfo')).data.customer.customerID;
        let token = JSON.parse(localStorage.getItem('wxUserInfo')).data.token;
		// 显示微信头像
		$('#wxImg').attr('src',getWxImg)

		fetch(`${api}/customer/${customerID}`, {
                method: "get",
                headers: {
                    'Content-type': 'application/json',
                    "Authorization": token
                }
            })
                .then(res => res.json())
				.then(data => {
					console.log(data)
					// 姓名
					data.data.customerName ? $('#userName').text(data.data.customerName) : '--'
					// 电话号码
					data.data.phoneNumber ? $('#phone').text(data.data.phoneNumber) : '--'
				})
		// 公司名称
		let companyName = ''
		if(userinfo.customer.enterpriseName.length > 7){
			companyName = userinfo.customer.enterpriseName.substring(0,7)+'..';
			console.log(companyName)
		}else{
			companyName = userinfo.customer.enterpriseName;
		}
		userinfo.customer.enterpriseName == null 
			? $('#company').html('<a href="#" class="blur-color popupsBtn"  style="display:inline-block;color: #fff;font-size:12px;float:left; width:86px;height:20px;background:rgba(14,138,229,1);border-radius:6px;text-align: center;margin-top: 0px;">未加入公司</a>') 
			: $('#company').html(companyName)

		//点击加入公司时弹窗
		$('#company').on('click', function () {
			$('.popup').css('display', 'block')
			$('#closePopup').click(function () {
				$('.popup').css('display', 'none')
			})
			$('.popup-content-bg').click(function () {
				$('.popup').css('display', 'none')
			})
		})
	}
</script>

</html>